﻿@model PsCommandDtls

@{
    GERPContext db = new GERPContext(true);
    var CommandModel = db.PsCommands.Find(Model.CmdId);
}

@using (Html.BeginForm("CreateDetail", "CommandMove", FormMethod.Post))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    <h3 class="header">เพิ่มรายชื่อในคำสั่ง</h3>
    <div class="detail">
        <h3><label id="lblCmdTypeName"></label></h3>
        @Html.HiddenFor(model => model.CmdId)
        @Html.HiddenFor(model => model.CmdDtlsId)

        <table class="info">
            <tr class="left2">
                <td class="editor-label">
                    @Html.LabelFor(model => model.EmpId)
                </td>
                <td class="editor-field">
                    @(Html.Telerik().ComboBoxFor(m => m.EmpId)
                        .BindTo(new SelectList(new GERPContext(true).Employees
                            .OrderBy(m => m.FirstName)
                            //.OrderBy(m => m.LastName)
                            .Where(m => m.RecordStatus != "D" && m.MasEmployeeStatus.Active == "1" && m.EmpTypeId == CommandModel.EmpTypeId)
                            .ToList(), "EmpId", "FullName"))
                        //.SelectedIndex(Model != null ? (model.HrmPsCommandDtls.EmpId != null ? model.HrmPsCommandDtls.EmpId.Value : -1) : -1)
                        .HighlightFirstMatch(true)
                        .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
                        .ClientEvents(client => client.OnChange("ddlEmpChange"))
                    )
                    @Html.ValidationMessageFor(model => model.EmpId)
                </td>
            </tr>
            <tr class="left">
                <td class="editor-label">
                    @Html.LabelFor(model => model.StartDate)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.StartDate)
                    @Html.ValidationMessageFor(model => model.StartDate)
                </td>
            </tr>
            <tr class="left">
                <td class="editor-label">
                    @Html.LabelFor(model => model.Remarks)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.Remarks)
                    @Html.ValidationMessageFor(model => model.Remarks)
                </td>
            </tr>
            <tr class="left2">
                <td class="editor-label">
                    @Html.LabelFor(model => model.RptRemarks)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.RptRemarks)
                    @Html.ValidationMessageFor(model => model.RptRemarks)
                </td>
            </tr>
        </table>
        <table class="info">
            <tr>
                <th>

                </th>
                <th colspan="1">
                    ข้อมูลเดิม
                </th>
                <th colspan="1">
                    ข้อมูลใหม่
                </th>
            </tr>
            <tr>
                <td class="editor-label" width="150px">
                    ตำแหน่ง
                </td>
                <td class="editor-field" width="300px">
                    @Html.HiddenFor(model => model.OldPosId)
                    @Html.TextBoxFor(model => model.OldPosRef, new { disabled="disabled", style="width:50px;" }) : 
                    @Html.TextBoxFor(model => model.OldPosName, new { disabled="disabled", style="width:150px;" } )
                    @Html.ValidationMessageFor(model => model.OldPosId)
                </td>
                <td class="editor-field" width="300px">
                    @(Html.Telerik().ComboBoxFor(m => m.NewPosId)
                        .BindTo(new SelectList(new GERPContext(true).Positions
                            .Where(m => m.RecordStatus != "D" && m.EmpTypeId == CommandModel.EmpTypeId)
                            .ToList().OrderBy(m => m.PosNo), "PosId", "PosText"))
                        //.SelectedIndex(Model != null ? (Model.EmpTypeId != null ? Model.EmpTypeId.Value : -1) : -1)
                        .HighlightFirstMatch(true)
                        .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
                        .ClientEvents(client => client.OnChange("ddlNewPosChange"))
                    )
                    <br/>@Html.HiddenFor(m => m.NewPosRef)
                    @Html.HiddenFor(m => m.NewPosName)
                        
                    @Html.ValidationMessageFor(model => model.NewPosId)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    ระดับ
                </td>
                <td class="editor-field">
                    @Html.HiddenFor(model => model.OldClassId)
                    @Html.TextBoxFor(model => model.old_HrmMpClasses.ClassName, new { disabled = "disabled" })
                    @Html.ValidationMessageFor(model => model.OldClassId)
                </td>
                <td class="editor-field">
                    @(Html.Telerik().ComboBoxFor(m => m.NewClassId)
                        .BindTo(new SelectList(new GERPContext(true).MpClass
                            .Where(m => m.RecordStatus != "D" && m.EmpTypeId == CommandModel.EmpTypeId)
                            .ToList(), "ClassId", "ClassName"))
                        //.SelectedIndex(Model != null ? (Model.EmpTypeId != null ? Model.EmpTypeId.Value : -1) : -1)
                        .HighlightFirstMatch(true)
                        .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
                        //.ClientEvents(client => client.OnChange("ddlNewClassChange"))
                    )
                        
                    @Html.ValidationMessageFor(model => model.NewClassId)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    ตำแหน่งบริหาร
                </td>
                <td class="editor-field">
                    @Html.TextBoxFor(model => model.OldExecPosName, new { disabled = "disabled" })
                    @Html.ValidationMessageFor(model => model.OldExecPosName)
                </td>
                <td class="editor-field">
                    @(Html.Telerik().ComboBoxFor(m => m.NewExecPosName)
                        .BindTo(new SelectList(new GERPContext(true).ExecutivePositions 
                            .Where(m => m.RecordStatus != "D")
                            .Distinct()
                            .ToList(), "ExecPosId", "Name"))
                        //.SelectedIndex(Model != null ? (Model.EmpTypeId != null ? Model.EmpTypeId.Value : -1) : -1)
                        .HighlightFirstMatch(true)
                        .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
                        .ClientEvents(client => client.OnChange("ddlNewExecChange"))
                    )
                    <br/>@Html.HiddenFor(m => m.NewExecPosName)
                        
                    @Html.ValidationMessageFor(model => model.NewExecPosName)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    สังกัด
                </td>
                <td class="editor-field">
                    @Html.HiddenFor(model => model.OldJobSiteId)
                    @Html.TextBoxFor(model => model.OldJobSiteName, new { disabled = "disabled" })
                    @Html.ValidationMessageFor(model => model.OldJobSiteId)
                </td>
                <td class="editor-field">
                    @(Html.Telerik().ComboBoxFor(m => m.NewJobSiteId)
                        .BindTo(new SelectList(new GERPContext(true).JobSites
                            .Where(m => m.RecordStatus != "D" && m.JobSiteTypeId == 1)
                            .OrderBy(m => m.Name)
                            .ToList(), "JobSiteId", "Name"))
                        //.SelectedIndex(Model != null ? (Model.EmpTypeId != null ? Model.EmpTypeId.Value : -1) : -1)
                        .HighlightFirstMatch(true)
                        .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
                        .ClientEvents(client => client.OnChange("ddlNewJobSiteChange"))
                    )
                    <br/>@Html.HiddenFor(m => m.NewJobSiteName)
                        
                    @Html.ValidationMessageFor(model => model.NewJobSiteId)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    สังกัดที่ปฏิบัติงาน
                </td>
                <td class="editor-field">
                    @Html.HiddenFor(model => model.OldWorkingJobSiteId)
                    @Html.TextBoxFor(model => model.OldWorkingJobSiteName, new { disabled = "disabled" })
                    @Html.ValidationMessageFor(model => model.OldWorkingJobSiteId)
                </td>
                <td class="editor-field">
                    @(Html.Telerik().ComboBoxFor(m => m.NewWorkingJobSiteId)
                        .BindTo(new SelectList(new GERPContext(true).JobSites
                            .Where(m => m.RecordStatus != "D" && m.JobSiteTypeId == 2)
                            .OrderBy(m => m.Name)
                            .ToList(), "JobSiteId", "Name"))
                        //.SelectedIndex(Model != null ? (Model.EmpTypeId != null ? Model.EmpTypeId.Value : -1) : -1)
                        .HighlightFirstMatch(true)
                        .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
                        .ClientEvents(client => client.OnChange("ddlNewWorkingJobSiteChange"))
                    )
                    <br/>@Html.HiddenFor(m => m.NewWorkingJobSiteName)
                    
                        
                    @Html.ValidationMessageFor(model => model.NewWorkingJobSiteId)
                </td>
            </tr>
            <tr hidden visible="false">
                <td class="editor-label">
                    เงินเดือน
                </td>
                <td class="editor-field">
                    @Html.TextBoxFor(model => model.OldSalary)
                    @Html.ValidationMessageFor(model => model.OldSalary)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(m=> m.NewSalary) บาท
                    @Html.ValidationMessageFor(model => model.NewSalary)
                </td>
            </tr>
        </table>
    
        <p id="pnlCommand2">
            <input type="submit" value="บันทึก" />&nbsp;&nbsp;<a id="lnkCancel" title="คลิกเพื่อยกเลิกการแก้ไข" >ยกเลิก</a>
        </p>
    </div>
}

